package com.loong.service.impl;

import com.loong.mapper.AddressMapper;
import com.loong.mapper.impl.AddressMapperImpl;
import com.loong.pojo.Address;
import com.loong.service.AddressService;

import java.util.List;

public class AddressServiceImpl implements AddressService {
    @Override
    public List<Address> findAddressByUid(Integer uid) {
        AddressMapper addressMapper = new AddressMapperImpl();
        int i = uid;
        return addressMapper.selectAddressByUid(i);
    }

    @Override
    public void saveAddress(Address address) {
        AddressMapper addressMapper = new AddressMapperImpl();
        addressMapper.insertAddress(address);
    }

    @Override
    public void deleteAddressByAid(String aid) {
        AddressMapper addressMapper = new AddressMapperImpl();
        int i = Integer.parseInt(aid);
        addressMapper.deleteAddressByAid(i);
    }

    @Override
    public void setAddressToDefault(String aid) {
        AddressMapper addressMapper = new AddressMapperImpl();
        addressMapper.updateAddressToCommon();
        int i = Integer.parseInt(aid);
        addressMapper.updateAddressToDefault(i);
    }

    @Override
    public void updateAddress(Address address) {
        AddressMapper addressMapper = new AddressMapperImpl();
        addressMapper.updateAddress(address);
    }
}
